package cn.cutie.clotconfig.client.config;

import cn.cutie.clotconfig.client.repository.ClotRepository;
import cn.cutie.clotconfig.client.repository.ClotRepositoryChangeListener;
import org.springframework.context.ApplicationContext;

import java.util.Map;

/**
 * @Description:
 * @Author: Cutie
 * @CreateDate: 2024/5/10 20:14
 * @Version: 0.0.1
 */
public interface ClotConfigService extends ClotRepositoryChangeListener {

    static ClotConfigService getDefault(ApplicationContext applicationContext, ConfigMeta configMeta) {
        ClotRepository clotRepository = ClotRepository.getDefault(configMeta);
        Map<String, String> config = clotRepository.getConfig();
        ClotConfigService clotConfigService = new ClotConfigServiceImpl(applicationContext, config);
        clotRepository.addListener(clotConfigService);
        return clotConfigService;
    }

    String[] getPropertyNames();

    String getProperty(String name);
}
